﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/pages/master/WebList.Master"
    CodeBehind="AreaList.aspx.cs" Inherits="BF.Web.pages.BaseSystem.AreaManagement.AreaList" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="~/pages/UserControls/SysAreaTree.ascx" TagName="SysAreaTree" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceJs" runat="server">
    <script src="../../../script/OpenQuery.js" type="text/javascript"></script>
    <script type="text/javascript">

        //        //弹出查询条件页面
        //        function Query() {
        //            OpenQuery('divCondition', 120, 550, Refurbish);
        //            return false;
        //        }

        //        //回发
        //        function Refurbish() {
        //            if ($("#=iFlag.ClientID %>").attr("checked") == true) {
        //                $("#=lbtnStop.ClientID %>>span>img").attr("src", "../../../../images/table_delete.png");
        //                $("#ctl00_ContentPlaceHtml_lbtnStop").find("div").text("停用");
        //            }
        //            else {
        //                $("#=lbtnStop.ClientID %>>span>img").attr("src", "../../../../images/table_add.png");
        //                $("#ctl00_ContentPlaceHtml_lbtnStop").find("div").text("启用");
        //            }
        //            __doPostBack("ctl00$ContentPlaceHtml$btnQuery", "");
        //        }

        //弹出添加页面
        function Add() {
            winer.OpenWin('行政区划新增', GetUrl(this) + 'AreaEdit.aspx', 700, 390, false, this);
            return false;
        }

        //停用前台方法
        function Stop() {
            if ($("#div_scroll_x :checkbox:checked").length == 0) {
                if ($("#ctl00_ContentPlaceHtml_lbtnStop").find("div").text() == "停用") {
                    Ext.MessageBox.show({ title: '提示', msg: '请选择要停用的记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                    return false;
                }
                else if ($("#ctl00_ContentPlaceHtml_lbtnStop").find("div").text() == "启用") {
                    Ext.MessageBox.show({ title: '提示', msg: '请选择要启用的记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                    return false;
                }
            }
            else {
                if ($("#ctl00_ContentPlaceHtml_lbtnStop").find("div").text() == "停用") {
                    Ext.MessageBox.show({
                        title: '提示',
                        msg: '是否确认要停用记录？',
                        buttons: { yes: '确  定', no: '取 消' },
                        fn: function (result) {
                            if (result == "yes") {
                                __doPostBack("ctl00$ContentPlaceHtml$lbtnStop", "");
                            }
                        },
                        icon: 'question'
                    });
                    return false;
                }
                else if ($("#ctl00_ContentPlaceHtml_lbtnStop").find("div").text() == "启用") {
                    Ext.MessageBox.show({
                        title: '提示',
                        msg: '是否确认要启用记录？',
                        buttons: { yes: '确  定', no: '取 消' },
                        fn: function (result) {
                            if (result == "yes") {
                                __doPostBack("ctl00$ContentPlaceHtml$lbtnStop", "");
                            }
                        },
                        icon: 'question'
                    });
                    return false;
                }

            }
        }

        //修改前台方法
        function Update() {
            if ($("input[name*='chksuserid']:checked").length == 0) {
                //                SelectOneWarning(""); //修改弹出框--修改时只能选择一条数据进行（参数：提示信息，不传值时有默认提示信息）
                Ext.MessageBox.show({ title: '提示', msg: '请选择要修改的数据！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            if ($("input[name*='chksuserid']:checked").length > 1) {//只能选择一项的判断
                Ext.MessageBox.show({ title: '提示', msg: '只能选择一条记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                return false;
            }
            var values = $("input[name*='chksuserid']:checked'").val();
            winer.OpenWin('行政区划修改', GetUrl(this) + 'AreaEdit.aspx?sID=' + values, 700, 390, false, this);
            return false;
        }

        //查看前台方法
        function View(id) {
            //            if ($("input[name*='chksuserid']:checked").length == 0) {//只能选择一项的判断
            //                //                SelectOneWarning(""); //修改弹出框--修改时只能选择一条数据进行（参数：提示信息，不传值时有默认提示信息）
            //                Ext.MessageBox.show({ title: '提示', msg: '请选择要查看的记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
            //                return false;
            //            }
            //            if ($("input[name*='chksuserid']:checked").length > 1) {//只能选择一项的判断
            //                Ext.MessageBox.show({ title: '提示', msg: '只能选择一条查看记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
            //                return false;
            //            }
            // var values = $("input[name*='chksuserid']:checked").val();
            winer.OpenWin('行政区划查看', GetUrl(this) + 'AreaEdit.aspx?State=View&sID=' + id, 700, 390, false, this);
            return false;
        }


        function validate() {
            var result = $("#aspnetForm").validate({
                rules: {
                    ctl00$ContentPlaceHtml$AreaQuery: {
                        maxlength: 20
                    }
                },
                messages: {
                    ctl00$ContentPlaceHtml$AreaQuery: {
                        maxlength: "*长度不超过20个字"
                    }
                },
                errorClass: "errorClass"
            });
            return result.form();
        }

        function MultipleSelect(obj) {
            if (obj.checked) {
                $("#div_scroll_x  :checkbox").attr("checked", true);
            }
            else {
                $("#div_scroll_x :checkbox:checked").each(function () {
                    $(this).attr("checked", false);
                })
            }
        }
        //控制checkbox在单选模式时，只能单选
        function Controlcheck(obj) {
            if (!$("#chxIsMultipleSelect").attr("checked")) {
                if (obj.checked) {
                    $("#div_scroll_x  :checkbox:checked").not(obj).attr("checked", false);
                }
            }
        }
        function checkStop(obj) {

            Controlcheck(obj);

            //停用启用状态
            var state = "";
            $("#div_scroll_x :checkbox:checked").each(function () {
                state += $(this).attr("accesskey") + "#";
            })

            if (state.indexOf("0#1#") != -1 || state.indexOf("1#0#") != -1) {
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("disabled", "disabled");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("href", "javascript:void(0);");
                return false;
            }
            if (state.indexOf("0#") != -1) {

                $("#ctl00_ContentPlaceHtml_hideStop").val("1");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("disabled", "");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("href", " javascript: __doPostBack('ctl00$ContentPlaceHtml$lbtnStop', '')")
                $('#divStop').html('启用');

                titleStop = "提示";
                msgStop = "请选择要启用的记录！";
                configStop = "是否确认要启用记录？";
                return false;
            }
            if (state.indexOf("1#") != -1) {
                $("#ctl00_ContentPlaceHtml_hideStop").val("0");
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("disabled", "");
                $('#divStop').html('停用');
                $("#ctl00_ContentPlaceHtml_lbtnStop").attr("href", " javascript: __doPostBack('ctl00$ContentPlaceHtml$lbtnStop', '')")
                titleStop = "提示";
                msgStop = "请选择要停用的记录！";
                configStop = "是否确认停用记录？";
                return false;
            }

        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHtml" runat="server">
    <table id="tabHead" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
        class="listtop1">
        <tr>
            <td id="QueryCondition" style="border-bottom: 1px solid #8db2e3;">
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-bottom: 5px;
                    margin-top: 4px;" class="content04 ">
                    <tr>
                        <td align="right">
                            所属行政区划：
                        </td>
                        <td>
                            <uc1:SysAreaTree ID="SysAreaTree1" runat="server" />
                        </td>
                        <td align="right">
                            行政区划名称：
                        </td>
                        <td>
                            <asp:TextBox ID="AreaQuery" runat="server" Width="138" MaxLength="20"></asp:TextBox>
                        </td>
                       <%-- <td align="right">
                            有效标识：
                        </td>
                        <td>
                            <asp:CheckBox ID="iFlag" runat="server" Checked="true" Text="*打√启用" />
                        </td>--%>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <table id="" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                    style="margin-bottom: 2px; margin-top: 2px; height: 26px;">
                    <tr>
                        <td>
                            <div class="btn01">
<%--                                <asp:ImageButton ID="ImageButton1" src="http://extjs.com/s.gif" class="icon icon-magnifier"
                                    runat="server" />--%>
                                <asp:LinkButton ID="btnQuery" runat="server" OnClick="btnQuery_Click">
                            <span>
                                <img alt="" src="http://extjs.com/s.gif" border="0" class="icon icon-magnifier" /><div class="center">
                                    查询</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="btnAdd" runat="server" OnClientClick="return Add();" Visible="false">
                            <span>
                                <img src="../../../images/table_add.png" alt="" border="0" /><div class="center">
                                    新增</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="btnUpdate" OnClientClick="return Update();" runat="server">
                            <span>
                                <img src="../../../images/table_edit.png" alt="" border="0" /><div class="center">
                                    修改</div>
                            </span>
                                </asp:LinkButton>
                                <asp:LinkButton ID="lbtnStop" runat="server" OnClientClick="return Stop();" OnClick="lbtnStop_Click">
                            <span>
                                <img src="../../../images/table_delete.png" alt="" border="0" /><div class="center" id="divStop">
                                    停用</div>
                            </span>
                                </asp:LinkButton>
                                <%-- 1：启用 0：停用--%>
                                <asp:HiddenField ID="hideStop" runat="server" Value="0" />
                                <%--<asp:LinkButton ID="lbtnLook" runat="server" OnClientClick="return View();">
                            <span>
                                <img src="../../../images/search.png" alt="" border="0" /><div class="center">
                                    查看</div>
                            </span>
                    </asp:LinkButton>--%>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <div id="div_scroll_x" class="div_scroll">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Repeater ID="Repeater1" runat="server">
                    <HeaderTemplate>
                        <table id="tbList" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                            class="list">
                            <thead>
                                <tr>
                                    <td align="center" style="width: 32px; padding-left: 4px;">
                                        <input id="chxIsMultipleSelect" type="checkbox" onclick="MultipleSelect(this)" />
                                    </td>
                                    <td align="center" style="width: 120px;">
                                        行政区划编码
                                    </td>
                                    <td align="center" style="width: 150px;">
                                        行政区划名称
                                    </td>
                                    <td align="center" style="width: 120px;">
                                        上级行政区划编码
                                    </td>
                                    <td align="center" style="width: 100px;">
                                        行政区划级别
                                    </td>
                                    <td align="center" style="width: 100px;">
                                        有效标识
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td align="center">
                                           <input type="checkbox" name="checkbox1" onclick="checkStop(this)" accesskey='<%#Eval("iFlag") %>'
                                    id="chksuserid" runat="server" value='<%#Eval("sID")%>' />
                                <input type="hidden" id="SYBZ" runat="server" value='<%#Eval("iFlag")%>' />

<%--                                <input type="checkbox" name="checkbox1" id="chksuserid" value='<%#Eval("sID")%>'
                                    runat="server" />--%>
                                <asp:Label ID="Label1" runat="server" Text='<%#Eval("iFlag").ToString().Trim() == "1" ? "是" : "否"%>'
                                    Visible="false"></asp:Label>
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#Eval("sID")%>'>
                                    <a href="#" onclick="View('<%#Eval("sID")%>')">
                                     <%#Eval("sID")%>
                                    </a>
                                    </div>
                            </td>
                            <td align="left" style='color: <%#Convert.ToString(Eval("iFlag")) == "1" ? "" : "#FF0000"%>'>
                                <div class="divnr-auto" title='<%#Eval("sName") %>'>
                                    &nbsp;&nbsp;<%#Eval("sName")%></div>
                            </td>
                            <td align="left" style='color: <%#Convert.ToString(Eval("iFlag")) == "1" ? "" : "#FF0000"%>'>
                                <div class="divnr-auto" title="<%#Eval("sSuperID") == null ? "" : Eval("sSuperID")%>">
                                    <%#Eval("sSuperID") == null ? "" : Eval("sSuperID")%></div>
                            </td>
                            <td align="left" style='color: <%#Convert.ToString(Eval("iFlag")) == "1" ? "" : "#FF0000"%>'>
                                <div class="divnr-auto" title='<%#Eval("iLevelName")%>'>
                                    <%#Eval("iLevelName")%></div>
                            </td>
                            <td align="center" style='color: <%#Convert.ToString(Eval("iFlag")) == "1" ? "" : "#FF0000"%>'>
                                <div class="divnr-auto" title="<%#Eval("iFlag").ToString()=="1"?"已启用":"已停用"%>">
                                    <%#Eval("iFlag").ToString() == "1" ? "已启用" : "已停用"%></div>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </tbody> </table>
                    </FooterTemplate>
                </asp:Repeater>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="AspNetPager1" EventName="PageChanged" />
                <asp:AsyncPostBackTrigger ControlID="lbtnStop" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnQuery" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <div class="div_AspNetPager">
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="fengye">
                    <tr>
                        <td>
                            <webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanged="AspNetPager1_PageChanged"
                                meta:resourcekey="AspNetPager1" PageSize="15"  SkinID="AspNetPager">
                            </webdiyer:AspNetPager>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="lbtnStop" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnQuery" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
        <input type="hidden" runat="server" id="SYBZ" />
</asp:Content>
